'''
Created on 24-Apr-2013

@author: cdac
'''
from SMS.DataSource import DataSource
from SMS.Stats import Stats

class Exp():
    '''
    classdocs
    '''
    def __init__(self, ham_source, spam_source):
        '''
        Constructor
        '''
        self.set_file_sources(ham_source, spam_source)
        self.init_data_sources()
        
    def extract_ham_stats(self, hams, dump_file_name):
        self.__ham_stats = Stats(hams, dump_file_name)
    
    def extract_spam_stats(self, spams, dump_file_name):
        self.__spam_stats = Stats(spams, dump_file_name)
    

    def set_file_sources(self, ham_source, spam_source):
        
        if len(ham_source) == 0:        
            self.__ham_file  = '../Data/HamSmall.csv'
            self.__ham_file  = '../Data/Ham.csv'
        else:
            self.__ham_file = ham_source
            
        if len(spam_source) == 0:
            self.__spam_file = '../Data/SpamSmall.csv'
            self.__spam_file = '../Data/Spam.csv'
        else:
            self.__spam_file = spam_source

    def init_data_sources(self):
        self.__ds_ham = DataSource(self.__ham_file)
        self.__ds_spam = DataSource(self.__spam_file)
                 
    def get_first_msgs_from_ham(self, how_many):
        return self.__ds_ham.get_first_msgs(how_many)   
        
    def get_first_msgs_from_spam(self, how_many):
        return self.__ds_spam.get_first_msgs(how_many)   

    def get_msgs_range_from_ham(self, from_msg_sample, to_msg_sample):
        return self.__ds_ham.get_msgs_in_range(from_msg_sample, to_msg_sample)
        
    def get_msgs_range_from_spam(self, from_msg_sample, to_msg_sample):
        return self.__ds_spam.get_msgs_in_range(from_msg_sample, to_msg_sample)
        
    def get_stats_for_hams(self):
        return self.__ham_stats
    
    def get_stats_for_spam(self):
        return self.__spam_stats
 